home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Programming / perlman / man / perlguts.txt < prev    next >
Encoding:
Text File  |  1999-09-09  |  70.2 KB  |  2,040 lines

  1. NAME
  2.        perlguts - Perl's Internal Functions
  3.  
  4. DESCRIPTION
  5.        This document attempts to describe some of the internal
  6.        functions of the Perl executable.  It is far from complete
  7.        and probably contains many errors.  Please refer any
  8.        questions or comments to the author below.
  9.  
  10. Datatypes
  11.        Perl has three typedefs that handle Perl's three main data
  12.        types:
  13.  
  14.            SV  Scalar Value
  15.            AV  Array Value
  16.            HV  Hash Value
  17.  
  18.        Each typedef has specific routines that manipulate the
  19.        various data types.
  20.  
  21.        What is an "IV"?
  22.  
  23.        Perl uses a special typedef IV which is large enough to
  24.        hold either an integer or a pointer.
  25.  
  26.        Perl also uses two special typedefs, I32 and I16, which
  27.        will always be at least 32-bits and 16-bits long,
  28.        respectively.
  29.  
  30.        Working with SV's
  31.  
  32.        An SV can be created and loaded with one command.  There
  33.        are four types of values that can be loaded: an integer
  34.        value (IV), a double (NV), a string, (PV), and another
  35.        scalar (SV).
  36.  
  37.        The four routines are:
  38.  
  39.            SV*  newSViv(IV);
  40.            SV*  newSVnv(double);
  41.            SV*  newSVpv(char*, int);
  42.            SV*  newSVsv(SV*);
  43.  
  44.        To change the value of an *already-existing* SV, there are
  45.        five routines:
  46.  
  47.            void  sv_setiv(SV*, IV);
  48.            void  sv_setnv(SV*, double);
  49.            void  sv_setpvn(SV*, char*, int)
  50.            void  sv_setpv(SV*, char*);
  51.            void  sv_setsv(SV*, SV*);
  52.  
  53.        Notice that you can choose to specify the length of the
  54.        string to be assigned by using sv_setpvn or newSVpv, or
  55.        you may allow Perl to calculate the length by using
  56.        sv_setpv or by specifying 0 as the second argument to
  57.        newSVpv.  Be warned, though, that Perl will determine the
  58.        string's length by using strlen, which depends on the
  59.        string terminating with a NUL character.
  60.  
  61.        To access the actual value that an SV points to, you can
  62.        use the macros:
  63.  
  64.            SvIV(SV*)
  65.            SvNV(SV*)
  66.            SvPV(SV*, STRLEN len)
  67.  
  68.        which will automatically coerce the actual scalar type
  69.        into an IV, double, or string.
  70.  
  71.        In the SvPV macro, the length of the string returned is
  72.        placed into the variable len (this is a macro, so you do
  73.        not use &len).  If you do not care what the length of the
  74.        data is, use the global variable na.  Remember, however,
  75.        that Perl allows arbitrary strings of data that may both
  76.        contain NUL's and not be terminated by a NUL.
  77.  
  78.        If you simply want to know if the scalar value is TRUE,
  79.        you can use:
  80.  
  81.            SvTRUE(SV*)
  82.  
  83.        Although Perl will automatically grow strings for you, if
  84.        you need to force Perl to allocate more memory for your
  85.        SV, you can use the macro
  86.  
  87.            SvGROW(SV*, STRLEN newlen)
  88.  
  89.        which will determine if more memory needs to be allocated.
  90.        If so, it will call the function sv_grow.  Note that
  91.        SvGROW can only increase, not decrease, the allocated
  92.        memory of an SV.
  93.  
  94.        If you have an SV and want to know what kind of data Perl
  95.        thinks is stored in it, you can use the following macros
  96.        to check the type of SV you have.
  97.  
  98.            SvIOK(SV*)
  99.            SvNOK(SV*)
  100.            SvPOK(SV*)
  101.  
  102.        You can get and set the current length of the string
  103.        stored in an SV with the following macros:
  104.  
  105.            SvCUR(SV*)
  106.            SvCUR_set(SV*, I32 val)
  107.  
  108.        You can also get a pointer to the end of the string stored
  109.        in the SV with the macro:
  110.  
  111.            SvEND(SV*)
  112.  
  113.        But note that these last three macros are valid only if
  114.        SvPOK() is true.
  115.  
  116.        If you want to append something to the end of string
  117.        stored in an SV*, you can use the following functions:
  118.  
  119.            void  sv_catpv(SV*, char*);
  120.            void  sv_catpvn(SV*, char*, int);
  121.            void  sv_catsv(SV*, SV*);
  122.  
  123.        The first function calculates the length of the string to
  124.        be appended by using strlen.  In the second, you specify
  125.        the length of the string yourself.  The third function
  126.        extends the string stored in the first SV with the string
  127.        stored in the second SV.  It also forces the second SV to
  128.        be interpreted as a string.
  129.  
  130.        If you know the name of a scalar variable, you can get a
  131.        pointer to its SV by using the following:
  132.  
  133.            SV*  perl_get_sv("varname", FALSE);
  134.  
  135.        This returns NULL if the variable does not exist.
  136.  
  137.        If you want to know if this variable (or any other SV) is
  138.        actually defined, you can call:
  139.  
  140.            SvOK(SV*)
  141.  
  142.        The scalar undef value is stored in an SV instance called
  143.        sv_undef.  Its address can be used whenever an SV* is
  144.        needed.
  145.  
  146.        There are also the two values sv_yes and sv_no, which
  147.        contain Boolean TRUE and FALSE values, respectively.  Like
  148.        sv_undef, their addresses can be used whenever an SV* is
  149.        needed.
  150.  
  151.        Do not be fooled into thinking that (SV *) 0 is the same
  152.        as &sv_undef.  Take this code:
  153.  
  154.            SV* sv = (SV*) 0;
  155.            if (I-am-to-return-a-real-value) {
  156.                    sv = sv_2mortal(newSViv(42));
  157.            }
  158.            sv_setsv(ST(0), sv);
  159.  
  160.        This code tries to return a new SV (which contains the
  161.        value 42) if it should return a real value, or undef
  162.        otherwise.  Instead it has returned a null pointer which,
  163.        somewhere down the line, will cause a segmentation
  164.        violation, or just weird results.  Change the zero to
  165.        &sv_undef in the first line and all will be well.
  166.  
  167.        To free an SV that you've created, call SvREFCNT_dec(SV*).
  168.        Normally this call is not necessary.  See the section on
  169.        MORTALITY.
  170.  
  171.        What's Really Stored in an SV?
  172.  
  173.        Recall that the usual method of determining the type of
  174.        scalar you have is to use Sv*OK macros.  Since a scalar
  175.        can be both a number and a string, usually these macros
  176.        will always return TRUE and calling the Sv*V macros will
  177.        do the appropriate conversion of string to integer/double
  178.        or integer/double to string.
  179.  
  180.        If you really need to know if you have an integer, double,
  181.        or string pointer in an SV, you can use the following
  182.        three macros instead:
  183.  
  184.            SvIOKp(SV*)
  185.            SvNOKp(SV*)
  186.            SvPOKp(SV*)
  187.  
  188.        These will tell you if you truly have an integer, double,
  189.        or string pointer stored in your SV.  The "p" stands for
  190.        private.
  191.  
  192.        In general, though, it's best to just use the Sv*V macros.
  193.  
  194.        Working with AV's
  195.  
  196.        There are two ways to create and load an AV.  The first
  197.        method just creates an empty AV:
  198.  
  199.            AV*  newAV();
  200.  
  201.        The second method both creates the AV and initially
  202.        populates it with SV's:
  203.  
  204.            AV*  av_make(I32 num, SV **ptr);
  205.  
  206.        The second argument points to an array containing num
  207.        SV*'s.  Once the AV has been created, the SV's can be
  208.        destroyed, if so desired.
  209.  
  210.        Once the AV has been created, the following operations are
  211.        possible on AV's:
  212.  
  213.            void  av_push(AV*, SV*);
  214.            SV*   av_pop(AV*);
  215.            SV*   av_shift(AV*);
  216.            void  av_unshift(AV*, I32 num);
  217.        These should be familiar operations, with the exception of
  218.        av_unshift.  This routine adds num elements at the front
  219.        of the array with the undef value.  You must then use
  220.        av_store (described below) to assign values to these new
  221.        elements.
  222.  
  223.        Here are some other functions:
  224.  
  225.            I32   av_len(AV*); /* Returns highest index value in array */
  226.  
  227.            SV**  av_fetch(AV*, I32 key, I32 lval);
  228.                    /* Fetches value at key offset, but it stores an undef value
  229.                       at the offset if lval is non-zero */
  230.            SV**  av_store(AV*, I32 key, SV* val);
  231.                    /* Stores val at offset key */
  232.  
  233.        Take note that av_fetch and av_store return SV**'s, not
  234.        SV*'s.
  235.  
  236.            void  av_clear(AV*);
  237.                    /* Clear out all elements, but leave the array */
  238.            void  av_undef(AV*);
  239.                    /* Undefines the array, removing all elements */
  240.            void  av_extend(AV*, I32 key);
  241.                    /* Extend the array to a total of key elements */
  242.  
  243.        If you know the name of an array variable, you can get a
  244.        pointer to its AV by using the following:
  245.  
  246.            AV*  perl_get_av("varname", FALSE);
  247.  
  248.        This returns NULL if the variable does not exist.
  249.  
  250.        Working with HV's
  251.  
  252.        To create an HV, you use the following routine:
  253.  
  254.            HV*  newHV();
  255.  
  256.        Once the HV has been created, the following operations are
  257.        possible on HV's:
  258.  
  259.            SV**  hv_store(HV*, char* key, U32 klen, SV* val, U32 hash);
  260.            SV**  hv_fetch(HV*, char* key, U32 klen, I32 lval);
  261.  
  262.        The klen parameter is the length of the key being passed
  263.        in.  The val argument contains the SV pointer to the
  264.        scalar being stored, and hash is the pre-computed hash
  265.        value (zero if you want hv_store to calculate it for you).
  266.        The lval parameter indicates whether this fetch is
  267.        actually a part of a store operation.
  268.  
  269.        Remember that hv_store and hv_fetch return SV**'s and not
  270.        just SV*.  In order to access the scalar value, you must
  271.        first dereference the return value.  However, you should
  272.        check to make sure that the return value is not NULL
  273.        before dereferencing it.
  274.  
  275.        These two functions check if a hash table entry exists,
  276.        and deletes it.
  277.  
  278.            bool  hv_exists(HV*, char* key, U32 klen);
  279.            SV*   hv_delete(HV*, char* key, U32 klen, I32 flags);
  280.  
  281.        And more miscellaneous functions:
  282.  
  283.            void   hv_clear(HV*);
  284.                    /* Clears all entries in hash table */
  285.            void   hv_undef(HV*);
  286.                    /* Undefines the hash table */
  287.  
  288.        Perl keeps the actual data in linked list of structures
  289.        with a typedef of HE.  These contain the actual key and
  290.        value pointers (plus extra administrative overhead).  The
  291.        key is a string pointer; the value is an SV*.  However,
  292.        once you have an HE*, to get the actual key and value, use
  293.        the routines specified below.
  294.  
  295.            I32    hv_iterinit(HV*);
  296.                    /* Prepares starting point to traverse hash table */
  297.            HE*    hv_iternext(HV*);
  298.                    /* Get the next entry, and return a pointer to a
  299.                       structure that has both the key and value */
  300.            char*  hv_iterkey(HE* entry, I32* retlen);
  301.                    /* Get the key from an HE structure and also return
  302.                       the length of the key string */
  303.            SV*    hv_iterval(HV*, HE* entry);
  304.                    /* Return a SV pointer to the value of the HE
  305.                       structure */
  306.            SV*    hv_iternextsv(HV*, char** key, I32* retlen);
  307.                    /* This convenience routine combines hv_iternext,
  308.                       hv_iterkey, and hv_iterval.  The key and retlen
  309.                       arguments are return values for the key and its
  310.                       length.  The value is returned in the SV* argument */
  311.  
  312.        If you know the name of a hash variable, you can get a
  313.        pointer to its HV by using the following:
  314.  
  315.            HV*  perl_get_hv("varname", FALSE);
  316.  
  317.        This returns NULL if the variable does not exist.
  318.  
  319.        The hash algorithm, for those who are interested, is:
  320.  
  321.            i = klen;
  322.            hash = 0;
  323.            s = key;
  324.            while (i--)
  325.                hash = hash * 33 + *s++;
  326.  
  327.        References
  328.  
  329.        References are a special type of scalar that point to
  330.        other data types (including references).
  331.  
  332.        To create a reference, use the following command:
  333.  
  334.            SV* newRV((SV*) thing);
  335.  
  336.        The thing argument can be any of an SV*, AV*, or HV*.
  337.        Once you have a reference, you can use the following macro
  338.        to dereference the reference:
  339.  
  340.            SvRV(SV*)
  341.  
  342.        then call the appropriate routines, casting the returned
  343.        SV* to either an AV* or HV*, if required.
  344.  
  345.        To determine if an SV is a reference, you can use the
  346.        following macro:
  347.  
  348.            SvROK(SV*)
  349.  
  350.        To actually discover what the reference refers to, you
  351.        must use the following macro and then check the value
  352.        returned.
  353.  
  354.            SvTYPE(SvRV(SV*))
  355.  
  356.        The most useful types that will be returned are:
  357.  
  358.            SVt_IV    Scalar
  359.            SVt_NV    Scalar
  360.            SVt_PV    Scalar
  361.            SVt_PVAV  Array
  362.            SVt_PVHV  Hash
  363.            SVt_PVCV  Code
  364.            SVt_PVMG  Blessed Scalar
  365.  
  366.        Blessed References and Class Objects
  367.  
  368.        References are also used to support object-oriented
  369.        programming.  In the OO lexicon, an object is simply a
  370.        reference that has been blessed into a package (or class).
  371.        Once blessed, the programmer may now use the reference to
  372.        access the various methods in the class.
  373.        A reference can be blessed into a package with the
  374.        following function:
  375.  
  376.            SV* sv_bless(SV* sv, HV* stash);
  377.  
  378.        The sv argument must be a reference.  The stash argument
  379.        specifies which class the reference will belong to.  See
  380.        the section on the Stashes manpage for information on
  381.        converting class names into stashes.
  382.  
  383.        /* Still under construction */
  384.  
  385.        Upgrades rv to reference if not already one.  Creates new
  386.        SV for rv to point to.  If classname is non-null, the SV
  387.        is blessed into the specified class.  SV is returned.
  388.  
  389.                SV* newSVrv(SV* rv, char* classname);
  390.  
  391.        Copies integer or double into an SV whose reference is rv.
  392.        SV is blessed if classname is non-null.
  393.  
  394.                SV* sv_setref_iv(SV* rv, char* classname, IV iv);
  395.                SV* sv_setref_nv(SV* rv, char* classname, NV iv);
  396.  
  397.        Copies pointer (not a string!) into an SV whose reference
  398.        is rv.  SV is blessed if classname is non-null.
  399.  
  400.                SV* sv_setref_pv(SV* rv, char* classname, PV iv);
  401.  
  402.        Copies string into an SV whose reference is rv.  Set
  403.        length to 0 to let Perl calculate the string length.  SV
  404.        is blessed if classname is non-null.
  405.  
  406.                SV* sv_setref_pvn(SV* rv, char* classname, PV iv, int length);
  407.  
  408.                int sv_isa(SV* sv, char* name);
  409.                int sv_isobject(SV* sv);
  410.  
  411. Creating New Variables
  412.        To create a new Perl variable, which can be accessed from
  413.        your Perl script, use the following routines, depending on
  414.        the variable type.
  415.  
  416.            SV*  perl_get_sv("varname", TRUE);
  417.            AV*  perl_get_av("varname", TRUE);
  418.            HV*  perl_get_hv("varname", TRUE);
  419.  
  420.        Notice the use of TRUE as the second parameter.  The new
  421.        variable can now be set, using the routines appropriate to
  422.        the data type.
  423.  
  424.        There are additional bits that may be OR'ed with the TRUE
  425.        argument to enable certain extra features.  Those bits
  426.        are:
  427.  
  428.            0x02  Marks the variable as multiply defined, thus preventing the
  429.                  "Indentifier <varname> used only once: possible typo" warning.
  430.            0x04  Issues a "Had to create <varname> unexpectedly" warning if
  431.                  the variable didn't actually exist.  This is useful if
  432.                  you expected the variable to already exist and want to propagate
  433.                  this warning back to the user.
  434.  
  435.        If the varname argument does not contain a package
  436.        specifier, it is created in the current package.
  437.  
  438. XSUB's and the Argument Stack
  439.        The XSUB mechanism is a simple way for Perl programs to
  440.        access C subroutines.  An XSUB routine will have a stack
  441.        that contains the arguments from the Perl program, and a
  442.        way to map from the Perl data structures to a C
  443.        equivalent.
  444.  
  445.        The stack arguments are accessible through the ST(n)
  446.        macro, which returns the n'th stack argument.  Argument 0
  447.        is the first argument passed in the Perl subroutine call.
  448.        These arguments are SV*, and can be used anywhere an SV*
  449.        is used.
  450.  
  451.        Most of the time, output from the C routine can be handled
  452.        through use of the RETVAL and OUTPUT directives.  However,
  453.        there are some cases where the argument stack is not
  454.        already long enough to handle all the return values.  An
  455.        example is the POSIX tzname() call, which takes no
  456.        arguments, but returns two, the local timezone's standard
  457.        and summer time abbreviations.
  458.  
  459.        To handle this situation, the PPCODE directive is used and
  460.        the stack is extended using the macro:
  461.  
  462.            EXTEND(sp, num);
  463.  
  464.        where sp is the stack pointer, and num is the number of
  465.        elements the stack should be extended by.
  466.  
  467.        Now that there is room on the stack, values can be pushed
  468.        on it using the macros to push IV's, doubles, strings, and
  469.        SV pointers respectively:
  470.  
  471.            PUSHi(IV)
  472.            PUSHn(double)
  473.            PUSHp(char*, I32)
  474.            PUSHs(SV*)
  475.  
  476.        And now the Perl program calling tzname, the two values
  477.        will be assigned as in:
  478.  
  479.            ($standard_abbrev, $summer_abbrev) = POSIX::tzname;
  480.        An alternate (and possibly simpler) method to pushing
  481.        values on the stack is to use the macros:
  482.  
  483.            XPUSHi(IV)
  484.            XPUSHn(double)
  485.            XPUSHp(char*, I32)
  486.            XPUSHs(SV*)
  487.  
  488.        These macros automatically adjust the stack for you, if
  489.        needed.
  490.  
  491.        For more information, consult the perlxs manpage.
  492.  
  493. Mortality
  494.        In Perl, values are normally "immortal" -- that is, they
  495.        are not freed unless explicitly done so (via the Perl
  496.        undef call or other routines in Perl itself).
  497.  
  498.        Add cruft about reference counts.       int SvREFCNT(SV*
  499.        sv);      void SvREFCNT_inc(SV* sv);      void
  500.        SvREFCNT_dec(SV* sv);
  501.  
  502.        In the above example with tzname, we needed to create two
  503.        new SV's to push onto the argument stack, that being the
  504.        two strings.  However, we don't want these new SV's to
  505.        stick around forever because they will eventually be
  506.        copied into the SV's that hold the two scalar variables.
  507.  
  508.        An SV (or AV or HV) that is "mortal" acts in all ways as a
  509.        normal "immortal" SV, AV, or HV, but is only valid in the
  510.        "current context".  When the Perl interpreter leaves the
  511.        current context, the mortal SV, AV, or HV is automatically
  512.        freed.  Generally the "current context" means a single
  513.        Perl statement.
  514.  
  515.        To create a mortal variable, use the functions:
  516.  
  517.            SV*  sv_newmortal()
  518.            SV*  sv_2mortal(SV*)
  519.            SV*  sv_mortalcopy(SV*)
  520.  
  521.        The first call creates a mortal SV, the second converts an
  522.        existing SV to a mortal SV, the third creates a mortal
  523.        copy of an existing SV.
  524.  
  525.        The mortal routines are not just for SV's -- AV's and HV's
  526.        can be made mortal by passing their address (and casting
  527.        them to SV*) to the sv_2mortal or sv_mortalcopy routines.
  528.  
  529.        >From Ilya: Beware that the sv_2mortal() call is
  530.        eventually equivalent to svREFCNT_dec(). A value can
  531.        happily be mortal in two different contexts, and it will
  532.        be svREFCNT_dec()ed twice, once on exit from these
  533.        contexts. It can also be mortal twice in the same context.
  534.        This means that you should be very careful to make a value
  535.        mortal exactly as many times as it is needed. The value
  536.        that go to the Perl stack should be mortal.
  537.  
  538.        You should be careful about creating mortal variables.  It
  539.        is possible for strange things to happen should you make
  540.        the same value mortal within multiple contexts.
  541.  
  542. Stashes
  543.        A stash is a hash table (associative array) that contains
  544.        all of the different objects that are contained within a
  545.        package.  Each key of the stash is a symbol name (shared
  546.        by all the different types of objects that have the same
  547.        name), and each value in the hash table is called a GV
  548.        (for Glob Value).  This GV in turn contains references to
  549.        the various objects of that name, including (but not
  550.        limited to) the following:
  551.  
  552.            Scalar Value
  553.            Array Value
  554.            Hash Value
  555.            File Handle
  556.            Directory Handle
  557.            Format
  558.            Subroutine
  559.  
  560.        Perl stores various stashes in a separate GV structure
  561.        (for global variable) but represents them with an HV
  562.        structure.  The keys in this larger GV are the various
  563.        package names; the values are the GV*'s which are stashes.
  564.        It may help to think of a stash purely as an HV, and that
  565.        the term "GV" means the global variable hash.
  566.  
  567.        To get the stash pointer for a particular package, use the
  568.        function:
  569.  
  570.            HV*  gv_stashpv(char* name, I32 create)
  571.            HV*  gv_stashsv(SV*, I32 create)
  572.  
  573.        The first function takes a literal string, the second uses
  574.        the string stored in the SV.  Remember that a stash is
  575.        just a hash table, so you get back an HV*.  The create
  576.        flag will create a new package if it is set.
  577.  
  578.        The name that gv_stash*v wants is the name of the package
  579.        whose symbol table you want.  The default package is
  580.        called main.  If you have multiply nested packages, pass
  581.        their names to gv_stash*v, separated by :: as in the Perl
  582.        language itself.
  583.  
  584.        Alternately, if you have an SV that is a blessed
  585.        reference, you can find out the stash pointer by using:
  586.  
  587.            HV*  SvSTASH(SvRV(SV*));
  588.        then use the following to get the package name itself:
  589.  
  590.            char*  HvNAME(HV* stash);
  591.  
  592.        If you need to return a blessed value to your Perl script,
  593.        you can use the following function:
  594.  
  595.            SV*  sv_bless(SV*, HV* stash)
  596.  
  597.        where the first argument, an SV*, must be a reference, and
  598.        the second argument is a stash.  The returned SV* can now
  599.        be used in the same way as any other SV.
  600.  
  601.        For more information on references and blessings, consult
  602.        the perlref manpage.
  603.  
  604. Magic
  605.        [This section still under construction.  Ignore everything
  606.        here.  Post no bills.  Everything not permitted is
  607.        forbidden.]
  608.  
  609.        # Version 6, 1995/1/27
  610.  
  611.        Any SV may be magical, that is, it has special features
  612.        that a normal SV does not have.  These features are stored
  613.        in the SV structure in a linked list of struct magic's,
  614.        typedef'ed to MAGIC.
  615.  
  616.            struct magic {
  617.                MAGIC*      mg_moremagic;
  618.                MGVTBL*     mg_virtual;
  619.                U16         mg_private;
  620.                char        mg_type;
  621.                U8          mg_flags;
  622.                SV*         mg_obj;
  623.                char*       mg_ptr;
  624.                I32         mg_len;
  625.            };
  626.  
  627.        Note this is current as of patchlevel 0, and could change
  628.        at any time.
  629.  
  630.        Assigning Magic
  631.  
  632.        Perl adds magic to an SV using the sv_magic function:
  633.  
  634.            void sv_magic(SV* sv, SV* obj, int how, char* name, I32 namlen);
  635.  
  636.        The sv argument is a pointer to the SV that is to acquire
  637.        a new magical feature.
  638.  
  639.        If sv is not already magical, Perl uses the SvUPGRADE
  640.        macro to set the SVt_PVMG flag for the sv.  Perl then
  641.        continues by adding it to the beginning of the linked list
  642.        of magical features.  Any prior entry of the same type of
  643.        magic is deleted.  Note that this can be overriden, and
  644.        multiple instances of the same type of magic can be
  645.        associated with an SV.
  646.  
  647.        The name and namlem arguments are used to associate a
  648.        string with the magic, typically the name of a variable.
  649.        namlem is stored in the mg_len field and if name is non-
  650.        null and namlem >= 0 a malloc'd copy of the name is stored
  651.        in mg_ptr field.
  652.  
  653.        The sv_magic function uses how to determine which, if any,
  654.        predefined "Magic Virtual Table" should be assigned to the
  655.        mg_virtual field.  See the "Magic Virtual Table" section
  656.        below.  The how argument is also stored in the mg_type
  657.        field.
  658.  
  659.        The obj argument is stored in the mg_obj field of the
  660.        MAGIC structure.  If it is not the same as the sv
  661.        argument, the reference count of the obj object is
  662.        incremented.  If it is the same, or if the how argument is
  663.        "#", or if it is a null pointer, then obj is merely
  664.        stored, without the reference count being incremented.
  665.  
  666.        There is also a function to add magic to an HV:
  667.  
  668.            void hv_magic(HV *hv, GV *gv, int how);
  669.  
  670.        This simply calls sv_magic and coerces the gv argument
  671.        into an SV.
  672.  
  673.        To remove the magic from an SV, call the function
  674.        sv_unmagic:
  675.  
  676.            void sv_unmagic(SV *sv, int type);
  677.  
  678.        The type argument should be equal to the how value when
  679.        the SV was initially made magical.
  680.  
  681.        Magic Virtual Tables
  682.  
  683.        The mg_virtual field in the MAGIC structure is a pointer
  684.        to a MGVTBL, which is a structure of function pointers and
  685.        stands for "Magic Virtual Table" to handle the various
  686.        operations that might be applied to that variable.
  687.  
  688.        The MGVTBL has five pointers to the following routine
  689.        types:
  690.  
  691.            int  (*svt_get)(SV* sv, MAGIC* mg);
  692.            int  (*svt_set)(SV* sv, MAGIC* mg);
  693.            U32  (*svt_len)(SV* sv, MAGIC* mg);
  694.            int  (*svt_clear)(SV* sv, MAGIC* mg);
  695.            int  (*svt_free)(SV* sv, MAGIC* mg);
  696.        This MGVTBL structure is set at compile-time in perl.h and
  697.        there are currently 19 types (or 21 with overloading
  698.        turned on).  These different structures contain pointers
  699.        to various routines that perform additional actions
  700.        depending on which function is being called.
  701.  
  702.            Function pointer    Action taken
  703.            ----------------    ------------
  704.            svt_get             Do something after the value of the SV is retrieved.
  705.            svt_set             Do something after the SV is assigned a value.
  706.            svt_len             Report on the SV's length.
  707.            svt_clear           Clear something the SV represents.
  708.            svt_free            Free any extra storage associated with the SV.
  709.  
  710.        For instance, the MGVTBL structure called vtbl_sv (which
  711.        corresponds to an mg_type of '\0') contains:
  712.  
  713.            { magic_get, magic_set, magic_len, 0, 0 }
  714.  
  715.        Thus, when an SV is determined to be magical and of type
  716.        '\0', if a get operation is being performed, the routine
  717.        magic_get is called.  All the various routines for the
  718.        various magical types begin with magic_.
  719.  
  720.        The current kinds of Magic Virtual Tables are:
  721.  
  722.            mg_type  MGVTBL              Type of magicalness
  723.            -------  ------              -------------------
  724.            \0       vtbl_sv             Regexp???
  725.            A        vtbl_amagic         Operator Overloading
  726.            a        vtbl_amagicelem     Operator Overloading
  727.            c        0                   Used in Operator Overloading
  728.            B        vtbl_bm             Boyer-Moore???
  729.            E        vtbl_env            %ENV hash
  730.            e        vtbl_envelem        %ENV hash element
  731.            g        vtbl_mglob          Regexp /g flag???
  732.            I        vtbl_isa            @ISA array
  733.            i        vtbl_isaelem        @ISA array element
  734.            L        0 (but sets RMAGICAL)     Perl Module/Debugger???
  735.            l        vtbl_dbline         Debugger?
  736.            P        vtbl_pack           Tied Array or Hash
  737.            p        vtbl_packelem       Tied Array or Hash element
  738.            q        vtbl_packelem       Tied Scalar or Handle
  739.            S        vtbl_sig            Signal Hash
  740.            s        vtbl_sigelem        Signal Hash element
  741.            t        vtbl_taint          Taintedness
  742.            U        vtbl_uvar           ???
  743.            v        vtbl_vec            Vector
  744.            x        vtbl_substr         Substring???
  745.            *        vtbl_glob           GV???
  746.            #        vtbl_arylen         Array Length
  747.            .        vtbl_pos            $. scalar variable
  748.            ~        Reserved for extensions, but multiple extensions may clash
  749.  
  750.        When an upper-case and lower-case letter both exist in the
  751.        table, then the upper-case letter is used to represent
  752.        some kind of composite type (a list or a hash), and the
  753.        lower-case letter is used to represent an element of that
  754.        composite type.
  755.  
  756.        Finding Magic
  757.  
  758.            MAGIC* mg_find(SV*, int type); /* Finds the magic pointer of that type */
  759.  
  760.        This routine returns a pointer to the MAGIC structure
  761.        stored in the SV.  If the SV does not have that magical
  762.        feature, NULL is returned.  Also, if the SV is not of type
  763.        SVt_PVMG, Perl may core-dump.
  764.  
  765.            int mg_copy(SV* sv, SV* nsv, char* key, STRLEN klen);
  766.  
  767.        This routine checks to see what types of magic sv has.  If
  768.        the mg_type field is an upper-case letter, then the mg_obj
  769.        is copied to nsv, but the mg_type field is changed to be
  770.        the lower-case letter.
  771.  
  772. Double-Typed SV's
  773.        Scalar variables normally contain only one type of value,
  774.        an integer, double, pointer, or reference.  Perl will
  775.        automatically convert the actual scalar data from the
  776.        stored type into the requested type.
  777.  
  778.        Some scalar variables contain more than one type of scalar
  779.        data.  For example, the variable $! contains either the
  780.        numeric value of errno or its string equivalent from
  781.        either strerror or sys_errlist[].
  782.  
  783.        To force multiple data values into an SV, you must do two
  784.        things: use the sv_set*v routines to add the additional
  785.        scalar type, then set a flag so that Perl will believe it
  786.        contains more than one type of data.  The four macros to
  787.        set the flags are:
  788.  
  789.                SvIOK_on
  790.                SvNOK_on
  791.                SvPOK_on
  792.                SvROK_on
  793.  
  794.        The particular macro you must use depends on which
  795.        sv_set*v routine you called first.  This is because every
  796.        sv_set*v routine turns on only the bit for the particular
  797.        type of data being set, and turns off all the rest.
  798.  
  799.        For example, to create a new Perl variable called
  800.        "dberror" that contains both the numeric and descriptive
  801.        string error values, you could use the following code:
  802.  
  803.            extern int  dberror;
  804.            extern char *dberror_list;
  805.  
  806.            SV* sv = perl_get_sv("dberror", TRUE);
  807.            sv_setiv(sv, (IV) dberror);
  808.            sv_setpv(sv, dberror_list[dberror]);
  809.            SvIOK_on(sv);
  810.  
  811.        If the order of sv_setiv and sv_setpv had been reversed,
  812.        then the macro SvPOK_on would need to be called instead of
  813.        SvIOK_on.
  814.  
  815. Calling Perl Routines from within C Programs
  816.        There are four routines that can be used to call a Perl
  817.        subroutine from within a C program.  These four are:
  818.  
  819.            I32  perl_call_sv(SV*, I32);
  820.            I32  perl_call_pv(char*, I32);
  821.            I32  perl_call_method(char*, I32);
  822.            I32  perl_call_argv(char*, I32, register char**);
  823.  
  824.        The routine most often used is perl_call_sv.  The SV*
  825.        argument contains either the name of the Perl subroutine
  826.        to be called, or a reference to the subroutine.  The
  827.        second argument consists of flags that control the context
  828.        in which the subroutine is called, whether or not the
  829.        subroutine is being passed arguments, how errors should be
  830.        trapped, and how to treat return values.
  831.  
  832.        All four routines return the number of arguments that the
  833.        subroutine returned on the Perl stack.
  834.  
  835.        When using any of these routines (except perl_call_argv),
  836.        the programmer must manipulate the Perl stack.  These
  837.        include the following macros and functions:
  838.  
  839.            dSP
  840.            PUSHMARK()
  841.            PUTBACK
  842.            SPAGAIN
  843.            ENTER
  844.            SAVETMPS
  845.            FREETMPS
  846.            LEAVE
  847.            XPUSH*()
  848.            POP*()
  849.  
  850.        For more information, consult the perlcall manpage.
  851.  
  852. Memory Allocation
  853.        It is strongly suggested that you use the version of
  854.        malloc that is distributed with Perl.  It keeps pools of
  855.        various sizes of unallocated memory in order to more
  856.        quickly satisfy allocation requests.  However, on some
  857.        platforms, it may cause spurious malloc or free errors.
  858.  
  859.            New(x, pointer, number, type);
  860.            Newc(x, pointer, number, type, cast);
  861.            Newz(x, pointer, number, type);
  862.  
  863.        These three macros are used to initially allocate memory.
  864.        The first argument x was a "magic cookie" that was used to
  865.        keep track of who called the macro, to help when debugging
  866.        memory problems.  However, the current code makes no use
  867.        of this feature (Larry has switched to using a run-time
  868.        memory checker), so this argument can be any number.
  869.  
  870.        The second argument pointer will point to the newly
  871.        allocated memory.  The third and fourth arguments number
  872.        and type specify how many of the specified type of data
  873.        structure should be allocated.  The argument type is
  874.        passed to sizeof.  The final argument to Newc, cast,
  875.        should be used if the pointer argument is different from
  876.        the type argument.
  877.  
  878.        Unlike the New and Newc macros, the Newz macro calls
  879.        memzero to zero out all the newly allocated memory.
  880.  
  881.            Renew(pointer, number, type);
  882.            Renewc(pointer, number, type, cast);
  883.            Safefree(pointer)
  884.  
  885.        These three macros are used to change a memory buffer size
  886.        or to free a piece of memory no longer needed.  The
  887.        arguments to Renew and Renewc match those of New and Newc
  888.        with the exception of not needing the "magic cookie"
  889.        argument.
  890.  
  891.            Move(source, dest, number, type);
  892.            Copy(source, dest, number, type);
  893.            Zero(dest, number, type);
  894.  
  895.        These three macros are used to move, copy, or zero out
  896.        previously allocated memory.  The source and dest
  897.        arguments point to the source and destination starting
  898.        points.  Perl will move, copy, or zero out number
  899.        instances of the size of the type data structure (using
  900.        the sizeof function).
  901.  
  902. API LISTING
  903.        This is a listing of functions, macros, flags, and
  904.        variables that may be useful to extension writers or that
  905.        may be found while reading other extensions.
  906.  
  907.        AvFILL  See av_len.
  908.  
  909.        av_clear
  910.                Clears an array, making it empty.
  911.                        void    av_clear _((AV* ar));
  912.  
  913.        av_extend
  914.                Pre-extend an array.  The key is the index to
  915.                which the array should be extended.
  916.  
  917.                        void    av_extend _((AV* ar, I32 key));
  918.  
  919.        av_fetch
  920.                Returns the SV at the specified index in the
  921.                array.  The key is the index.  If lval is set then
  922.                the fetch will be part of a store.  Check that the
  923.                return value is non-null before dereferencing it
  924.                to a SV*.
  925.  
  926.                        SV**    av_fetch _((AV* ar, I32 key, I32 lval));
  927.  
  928.        av_len  Returns the highest index in the array.  Returns
  929.                -1 if the array is empty.
  930.  
  931.                        I32     av_len _((AV* ar));
  932.  
  933.        av_make Creats a new AV and populates it with a list of
  934.                SVs.  The SVs are copied into the array, so they
  935.                may be freed after the call to av_make.
  936.  
  937.                        AV*     av_make _((I32 size, SV** svp));
  938.  
  939.        av_pop  Pops an SV off the end of the array.  Returns
  940.                &sv_undef if the array is empty.
  941.  
  942.                        SV*     av_pop _((AV* ar));
  943.  
  944.        av_push Pushes an SV onto the end of the array.
  945.  
  946.                        void    av_push _((AV* ar, SV* val));
  947.  
  948.        av_shift
  949.                Shifts an SV off the beginning of the array.
  950.  
  951.                        SV*     av_shift _((AV* ar));
  952.  
  953.        av_store
  954.                Stores an SV in an array.  The array index is
  955.                specified as key.  The return value will be null
  956.                if the operation failed, otherwise it can be
  957.                dereferenced to get the original SV*.
  958.  
  959.                        SV**    av_store _((AV* ar, I32 key, SV* val));
  960.  
  961.        av_undef
  962.                Undefines the array.
  963.  
  964.                        void    av_undef _((AV* ar));
  965.  
  966.        av_unshift
  967.                Unshift an SV onto the beginning of the array.
  968.  
  969.                        void    av_unshift _((AV* ar, I32 num));
  970.  
  971.        CLASS   Variable which is setup by xsubpp to indicate the
  972.                class name for a C++ XS constructor.  This is
  973.                always a char*.  See THIS and the perlxs manpage.
  974.  
  975.        Copy    The XSUB-writer's interface to the C memcpy
  976.                function.  The s is the source, d is the
  977.                destination, n is the number of items, and t is
  978.                the type.
  979.  
  980.                        (void) Copy( s, d, n, t );
  981.  
  982.        croak   This is the XSUB-writer's interface to Perl's die
  983.                function.  Use this function the same way you use
  984.                the C printf function.  See warn.
  985.  
  986.        CvSTASH Returns the stash of the CV.
  987.  
  988.                        HV * CvSTASH( SV* sv )
  989.  
  990.        DBsingle
  991.                When Perl is run in debugging mode, with the -d
  992.                switch, this SV is a boolean which indicates
  993.                whether subs are being single-stepped.  Single-
  994.                stepping is automatically turned on after every
  995.                step.  See DBsub.
  996.  
  997.        DBsub   When Perl is run in debugging mode, with the -d
  998.                switch, this GV contains the SV which holds the
  999.                name of the sub being debugged.  See DBsingle.
  1000.                The sub name can be found by
  1001.  
  1002.                        SvPV( GvSV( DBsub ), na )
  1003.  
  1004.        dMARK   Declare a stack marker for the XSUB.  See MARK and
  1005.                dORIGMARK.
  1006.  
  1007.        dORIGMARK
  1008.                Saves the original stack mark for the XSUB.  See
  1009.                ORIGMARK.
  1010.  
  1011.        dSP     Declares a stack pointer for the XSUB.  See SP.
  1012.  
  1013.        dXSARGS Sets up stack and mark pointers for an XSUB,
  1014.                calling dSP and dMARK.  This is usually handled
  1015.                automatically by xsubpp.  Declares the items
  1016.                variable to indicate the number of items on the
  1017.                stack.
  1018.  
  1019.        ENTER   Opening bracket on a callback.  See LEAVE and the
  1020.                perlcall manpage.
  1021.  
  1022.                        ENTER;
  1023.  
  1024.        EXTEND  Used to extend the argument stack for an XSUB's
  1025.                return values.
  1026.  
  1027.                        EXTEND( sp, int x );
  1028.  
  1029.        FREETMPS
  1030.                Closing bracket for temporaries on a callback.
  1031.                See SAVETMPS and the perlcall manpage.
  1032.  
  1033.                        FREETMPS;
  1034.  
  1035.        G_ARRAY Used to indicate array context.  See GIMME and the
  1036.                perlcall manpage.
  1037.  
  1038.        G_DISCARD
  1039.                Indicates that arguments returned from a callback
  1040.                should be discarded.  See the perlcall manpage.
  1041.  
  1042.        G_EVAL  Used to force a Perl eval wrapper around a
  1043.                callback.  See the perlcall manpage.
  1044.  
  1045.        GIMME   The XSUB-writer's equivalent to Perl's wantarray.
  1046.                Returns G_SCALAR or G_ARRAY for scalar or array
  1047.                context.
  1048.  
  1049.        G_NOARGS
  1050.                Indicates that no arguments are being sent to a
  1051.                callback.  See the perlcall manpage.
  1052.  
  1053.        G_SCALAR
  1054.                Used to indicate scalar context.  See GIMME and
  1055.                the perlcall manpage.
  1056.  
  1057.        gv_stashpv
  1058.                Returns a pointer to the stash for a specified
  1059.                package.  If create is set then the package will
  1060.                be created if it does not already exist.  If
  1061.                create is not set and the package does not exist
  1062.                then NULL is returned.
  1063.  
  1064.                        HV*     gv_stashpv _((char* name, I32 create));
  1065.  
  1066.        gv_stashsv
  1067.                Returns a pointer to the stash for a specified
  1068.                package.  See gv_stashpv.
  1069.  
  1070.                        HV*     gv_stashsv _((SV* sv, I32 create));
  1071.  
  1072.        GvSV    Return the SV from the GV.
  1073.  
  1074.        he_free Releases a hash entry from an iterator.  See
  1075.                hv_iternext.
  1076.  
  1077.        hv_clear
  1078.                Clears a hash, making it empty.
  1079.  
  1080.                        void    hv_clear _((HV* tb));
  1081.  
  1082.        hv_delete
  1083.                Deletes a key/value pair in the hash.  The value
  1084.                SV is removed from the hash and returned to the
  1085.                caller.  The lken is the length of the key.  The
  1086.                flags value will normally be zero; if set to
  1087.                G_DISCARD then null will be returned.
  1088.  
  1089.                        SV*     hv_delete _((HV* tb, char* key, U32 klen, I32 flags));
  1090.  
  1091.        hv_exists
  1092.                Returns a boolean indicating whether the specified
  1093.                hash key exists.  The lken is the length of the
  1094.                key.
  1095.  
  1096.                        bool    hv_exists _((HV* tb, char* key, U32 klen));
  1097.  
  1098.        hv_fetch
  1099.                Returns the SV which corresponds to the specified
  1100.                key in the hash.  The lken is the length of the
  1101.                key.  If lval is set then the fetch will be part
  1102.                of a store.  Check that the return value is non-
  1103.                null before dereferencing it to a SV*.
  1104.                        SV**    hv_fetch _((HV* tb, char* key, U32 klen, I32 lval));
  1105.  
  1106.        hv_iterinit
  1107.                Prepares a starting point to traverse a hash
  1108.                table.
  1109.  
  1110.                        I32     hv_iterinit _((HV* tb));
  1111.  
  1112.        hv_iterkey
  1113.                Returns the key from the current position of the
  1114.                hash iterator.  See hv_iterinit.
  1115.  
  1116.                        char*   hv_iterkey _((HE* entry, I32* retlen));
  1117.  
  1118.        hv_iternext
  1119.                Returns entries from a hash iterator.  See
  1120.                hv_iterinit.
  1121.  
  1122.                        HE*     hv_iternext _((HV* tb));
  1123.  
  1124.        hv_iternextsv
  1125.                Performs an hv_iternext, hv_iterkey, and
  1126.                hv_iterval in one operation.
  1127.  
  1128.                        SV *    hv_iternextsv _((HV* hv, char** key, I32* retlen));
  1129.  
  1130.        hv_iterval
  1131.                Returns the value from the current position of the
  1132.                hash iterator.  See hv_iterkey.
  1133.  
  1134.                        SV*     hv_iterval _((HV* tb, HE* entry));
  1135.  
  1136.        hv_magic
  1137.                Adds magic to a hash.  See sv_magic.
  1138.  
  1139.                        void    hv_magic _((HV* hv, GV* gv, int how));
  1140.  
  1141.        HvNAME  Returns the package name of a stash.  See SvSTASH,
  1142.                CvSTASH.
  1143.  
  1144.                        char *HvNAME (HV* stash)
  1145.  
  1146.        hv_store
  1147.                Stores an SV in a hash.  The hash key is specified
  1148.                as key and klen is the length of the key.  The
  1149.                hash parameter is the pre-computed hash value; if
  1150.                it is zero then Perl will compute it.  The return
  1151.                value will be null if the operation failed,
  1152.                otherwise it can be dereferenced to get the
  1153.                original SV*.
  1154.  
  1155.                        SV**    hv_store _((HV* tb, char* key, U32 klen, SV* val, U32 hash));
  1156.  
  1157.        hv_undef
  1158.                Undefines the hash.
  1159.  
  1160.                        void    hv_undef _((HV* tb));
  1161.  
  1162.        isALNUM Returns a boolean indicating whether the C char is
  1163.                an ascii alphanumeric character or digit.
  1164.  
  1165.                        int isALNUM (char c)
  1166.  
  1167.        isALPHA Returns a boolean indicating whether the C char is
  1168.                an ascii alphanumeric character.
  1169.  
  1170.                        int isALPHA (char c)
  1171.  
  1172.        isDIGIT Returns a boolean indicating whether the C char is
  1173.                an ascii digit.
  1174.  
  1175.                        int isDIGIT (char c)
  1176.  
  1177.        isLOWER Returns a boolean indicating whether the C char is
  1178.                a lowercase character.
  1179.  
  1180.                        int isLOWER (char c)
  1181.  
  1182.        isSPACE Returns a boolean indicating whether the C char is
  1183.                whitespace.
  1184.  
  1185.                        int isSPACE (char c)
  1186.  
  1187.        isUPPER Returns a boolean indicating whether the C char is
  1188.                an uppercase character.
  1189.  
  1190.                        int isUPPER (char c)
  1191.  
  1192.        items   Variable which is setup by xsubpp to indicate the
  1193.                number of items on the stack.  See the perlxs
  1194.                manpage.
  1195.  
  1196.        LEAVE   Closing bracket on a callback.  See ENTER and the
  1197.                perlcall manpage.
  1198.  
  1199.                        LEAVE;
  1200.  
  1201.        MARK    Stack marker for the XSUB.  See dMARK.
  1202.  
  1203.        mg_clear
  1204.                Clear something magical that the SV represents.
  1205.                See sv_magic.
  1206.  
  1207.                        int     mg_clear _((SV* sv));
  1208.  
  1209.        mg_copy Copies the magic from one SV to another.  See
  1210.                sv_magic.
  1211.  
  1212.                        int     mg_copy _((SV *, SV *, char *, STRLEN));
  1213.  
  1214.        mg_find Finds the magic pointer for type matching the SV.
  1215.                See sv_magic.
  1216.  
  1217.                        MAGIC*  mg_find _((SV* sv, int type));
  1218.  
  1219.        mg_free Free any magic storage used by the SV.  See
  1220.                sv_magic.
  1221.  
  1222.                        int     mg_free _((SV* sv));
  1223.  
  1224.        mg_get  Do magic after a value is retrieved from the SV.
  1225.                See sv_magic.
  1226.  
  1227.                        int     mg_get _((SV* sv));
  1228.  
  1229.        mg_len  Report on the SV's length.  See sv_magic.
  1230.  
  1231.                        U32     mg_len _((SV* sv));
  1232.  
  1233.        mg_magical
  1234.                Turns on the magical status of an SV.  See
  1235.                sv_magic.
  1236.  
  1237.                        void    mg_magical _((SV* sv));
  1238.  
  1239.        mg_set  Do magic after a value is assigned to the SV.  See
  1240.                sv_magic.
  1241.  
  1242.                        int     mg_set _((SV* sv));
  1243.  
  1244.        Move    The XSUB-writer's interface to the C memmove
  1245.                function.  The s is the source, d is the
  1246.                destination, n is the number of items, and t is
  1247.                the type.
  1248.  
  1249.                        (void) Move( s, d, n, t );
  1250.  
  1251.        na      A variable which may be used with SvPV to tell
  1252.                Perl to calculate the string length.
  1253.  
  1254.        New     The XSUB-writer's interface to the C malloc
  1255.                function.
  1256.  
  1257.                        void * New( x, void *ptr, int size, type )
  1258.  
  1259.        Newc    The XSUB-writer's interface to the C malloc
  1260.                function, with cast.
  1261.  
  1262.                        void * Newc( x, void *ptr, int size, type, cast )
  1263.  
  1264.        Newz    The XSUB-writer's interface to the C malloc
  1265.                function.  The allocated memory is zeroed with
  1266.                memzero.
  1267.  
  1268.                        void * Newz( x, void *ptr, int size, type )
  1269.  
  1270.        newAV   Creates a new AV.  The refcount is set to 1.
  1271.  
  1272.                        AV*     newAV _((void));
  1273.  
  1274.        newHV   Creates a new HV.  The refcount is set to 1.
  1275.  
  1276.                        HV*     newHV _((void));
  1277.  
  1278.        newRV   Creates an RV wrapper for an SV.  The refcount for
  1279.                the original SV is incremented.
  1280.  
  1281.                        SV*     newRV _((SV* ref));
  1282.  
  1283.        newSV   Creates a new SV.  The len parameter indicates the
  1284.                number of bytes of pre-allocated string space the
  1285.                SV should have.  The refcount for the new SV is
  1286.                set to 1.
  1287.  
  1288.                        SV*     newSV _((STRLEN len));
  1289.  
  1290.        newSViv Creates a new SV and copies an integer into it.
  1291.                The refcount for the SV is set to 1.
  1292.  
  1293.                        SV*     newSViv _((IV i));
  1294.  
  1295.        newSVnv Creates a new SV and copies a double into it.  The
  1296.                refcount for the SV is set to 1.
  1297.  
  1298.                        SV*     newSVnv _((NV i));
  1299.  
  1300.        newSVpv Creates a new SV and copies a string into it.  The
  1301.                refcount for the SV is set to 1.  If len is zero
  1302.                then Perl will compute the length.
  1303.  
  1304.                        SV*     newSVpv _((char* s, STRLEN len));
  1305.  
  1306.        newSVrv Creates a new SV for the RV, rv, to point to.  If
  1307.                rv is not an RV then it will be upgraded one.  If
  1308.                classname is non-null then the new SV will be
  1309.                blessed in the specified package.  The new SV is
  1310.                returned and its refcount is 1.
  1311.  
  1312.                        SV*     newSVrv _((SV* rv, char* classname));
  1313.  
  1314.        newSVsv Creates a new SV which is an exact duplicate of
  1315.                the orignal SV.
  1316.  
  1317.                        SV*     newSVsv _((SV* old));
  1318.  
  1319.        newXS   Used by xsubpp to hook up XSUBs as Perl subs.
  1320.  
  1321.        newXSproto
  1322.                Used by xsubpp to hook up XSUBs as Perl subs.
  1323.                Adds Perl prototypes to the subs.
  1324.  
  1325.        Nullav  Null AV pointer.
  1326.  
  1327.        Nullch  Null character pointer.
  1328.  
  1329.        Nullcv  Null CV pointer.
  1330.  
  1331.        Nullhv  Null HV pointer.
  1332.  
  1333.        Nullsv  Null SV pointer.
  1334.  
  1335.        ORIGMARK
  1336.                The original stack mark for the XSUB.  See
  1337.                dORIGMARK.
  1338.  
  1339.        perl_alloc
  1340.                Allocates a new Perl interpreter.  See the
  1341.                perlembed manpage.
  1342.  
  1343.        perl_call_argv
  1344.                Performs a callback to the specified Perl sub.
  1345.                See the perlcall manpage.
  1346.  
  1347.                        I32     perl_call_argv _((char* subname, I32 flags, char** argv));
  1348.  
  1349.        perl_call_method
  1350.                Performs a callback to the specified Perl method.
  1351.                The blessed object must be on the stack.  See the
  1352.                perlcall manpage.
  1353.  
  1354.                        I32     perl_call_method _((char* methname, I32 flags));
  1355.  
  1356.        perl_call_pv
  1357.                Performs a callback to the specified Perl sub.
  1358.                See the perlcall manpage.
  1359.  
  1360.                        I32     perl_call_pv _((char* subname, I32 flags));
  1361.  
  1362.        perl_call_sv
  1363.                Performs a callback to the Perl sub whose name is
  1364.                in the SV.  See the perlcall manpage.
  1365.  
  1366.                        I32     perl_call_sv _((SV* sv, I32 flags));
  1367.  
  1368.        perl_construct
  1369.                Initializes a new Perl interpreter.  See the
  1370.                perlembed manpage.
  1371.  
  1372.        perl_destruct
  1373.                Shuts down a Perl interpreter.  See the perlembed
  1374.                manpage.
  1375.  
  1376.        perl_eval_sv
  1377.                Tells Perl to eval the string in the SV.
  1378.  
  1379.                        I32     perl_eval_sv _((SV* sv, I32 flags));
  1380.  
  1381.        perl_free
  1382.                Releases a Perl interpreter.  See the perlembed
  1383.                manpage.
  1384.        perl_get_av
  1385.                Returns the AV of the specified Perl array.  If
  1386.                create is set and the Perl variable does not exist
  1387.                then it will be created.  If create is not set and
  1388.                the variable does not exist then null is returned.
  1389.  
  1390.                        AV*     perl_get_av _((char* name, I32 create));
  1391.  
  1392.        perl_get_cv
  1393.                Returns the CV of the specified Perl sub.  If
  1394.                create is set and the Perl variable does not exist
  1395.                then it will be created.  If create is not set and
  1396.                the variable does not exist then null is returned.
  1397.  
  1398.                        CV*     perl_get_cv _((char* name, I32 create));
  1399.  
  1400.        perl_get_hv
  1401.                Returns the HV of the specified Perl hash.  If
  1402.                create is set and the Perl variable does not exist
  1403.                then it will be created.  If create is not set and
  1404.                the variable does not exist then null is returned.
  1405.  
  1406.                        HV*     perl_get_hv _((char* name, I32 create));
  1407.  
  1408.        perl_get_sv
  1409.                Returns the SV of the specified Perl scalar.  If
  1410.                create is set and the Perl variable does not exist
  1411.                then it will be created.  If create is not set and
  1412.                the variable does not exist then null is returned.
  1413.  
  1414.                        SV*     perl_get_sv _((char* name, I32 create));
  1415.  
  1416.        perl_parse
  1417.                Tells a Perl interpreter to parse a Perl script.
  1418.                See the perlembed manpage.
  1419.  
  1420.        perl_require_pv
  1421.                Tells Perl to require a module.
  1422.  
  1423.                        void    perl_require_pv _((char* pv));
  1424.  
  1425.        perl_run
  1426.                Tells a Perl interpreter to run.  See the
  1427.                perlembed manpage.
  1428.  
  1429.        POPi    Pops an integer off the stack.
  1430.  
  1431.                        int POPi();
  1432.  
  1433.        POPl    Pops a long off the stack.
  1434.  
  1435.                        long POPl();
  1436.  
  1437.        POPp    Pops a string off the stack.
  1438.  
  1439.                        char * POPp();
  1440.  
  1441.        POPn    Pops a double off the stack.
  1442.  
  1443.                        double POPn();
  1444.  
  1445.        POPs    Pops an SV off the stack.
  1446.  
  1447.                        SV* POPs();
  1448.  
  1449.        PUSHMARK
  1450.                Opening bracket for arguments on a callback.  See
  1451.                PUTBACK and the perlcall manpage.
  1452.  
  1453.                        PUSHMARK(p)
  1454.  
  1455.        PUSHi   Push an integer onto the stack.  The stack must
  1456.                have room for this element.  See XPUSHi.
  1457.  
  1458.                        PUSHi(int d)
  1459.  
  1460.        PUSHn   Push a double onto the stack.  The stack must have
  1461.                room for this element.  See XPUSHn.
  1462.  
  1463.                        PUSHn(double d)
  1464.  
  1465.        PUSHp   Push a string onto the stack.  The stack must have
  1466.                room for this element.  The len indicates the
  1467.                length of the string.  See XPUSHp.
  1468.  
  1469.                        PUSHp(char *c, int len )
  1470.  
  1471.        PUSHs   Push an SV onto the stack.  The stack must have
  1472.                room for this element.  See XPUSHs.
  1473.  
  1474.                        PUSHs(sv)
  1475.  
  1476.        PUTBACK Closing bracket for XSUB arguments.  This is
  1477.                usually handled by xsubpp.  See PUSHMARK and the
  1478.                perlcall manpage for other uses.
  1479.  
  1480.                        PUTBACK;
  1481.  
  1482.        Renew   The XSUB-writer's interface to the C realloc
  1483.                function.
  1484.  
  1485.                        void * Renew( void *ptr, int size, type )
  1486.  
  1487.        Renewc  The XSUB-writer's interface to the C realloc
  1488.                function, with cast.
  1489.  
  1490.                        void * Renewc( void *ptr, int size, type, cast )
  1491.  
  1492.        RETVAL  Variable which is setup by xsubpp to hold the
  1493.                return value for an XSUB.  This is always the
  1494.                proper type for the XSUB.  See the perlxs manpage.
  1495.  
  1496.        safefree
  1497.                The XSUB-writer's interface to the C free
  1498.                function.
  1499.  
  1500.        safemalloc
  1501.                The XSUB-writer's interface to the C malloc
  1502.                function.
  1503.  
  1504.        saferealloc
  1505.                The XSUB-writer's interface to the C realloc
  1506.                function.
  1507.  
  1508.        savepv  Copy a string to a safe spot.  This does not use
  1509.                an SV.
  1510.  
  1511.                        char*   savepv _((char* sv));
  1512.  
  1513.        savepvn Copy a string to a safe spot.  The len indicates
  1514.                number of bytes to copy.  This does not use an SV.
  1515.  
  1516.                        char*   savepvn _((char* sv, I32 len));
  1517.  
  1518.        SAVETMPS
  1519.                Opening bracket for temporaries on a callback.
  1520.                See FREETMPS and the perlcall manpage.
  1521.  
  1522.                        SAVETMPS;
  1523.  
  1524.        SP      Stack pointer.  This is usually handled by xsubpp.
  1525.                See dSP and SPAGAIN.
  1526.        SPAGAIN Refetch the stack pointer.  Used after a callback.
  1527.                See the perlcall manpage.
  1528.  
  1529.                        SPAGAIN;
  1530.  
  1531.        ST      Used to access elements on the XSUB's stack.
  1532.  
  1533.                        SV* ST(int x)
  1534.  
  1535.        strEQ   Test two strings to see if they are equal.
  1536.                Returns true or false.
  1537.  
  1538.                        int strEQ( char *s1, char *s2 )
  1539.  
  1540.        strGE   Test two strings to see if the first, s1, is
  1541.                greater than or equal to the second, s2.  Returns
  1542.                true or false.
  1543.  
  1544.                        int strGE( char *s1, char *s2 )
  1545.  
  1546.        strGT   Test two strings to see if the first, s1, is
  1547.                greater than the second, s2.  Returns true or
  1548.                false.
  1549.  
  1550.                        int strGT( char *s1, char *s2 )
  1551.  
  1552.        strLE   Test two strings to see if the first, s1, is less
  1553.                than or equal to the second, s2.  Returns true or
  1554.                false.
  1555.  
  1556.                        int strLE( char *s1, char *s2 )
  1557.  
  1558.        strLT   Test two strings to see if the first, s1, is less
  1559.                than the second, s2.  Returns true or false.
  1560.  
  1561.                        int strLT( char *s1, char *s2 )
  1562.  
  1563.        strNE   Test two strings to see if they are different.
  1564.                Returns true or false.
  1565.  
  1566.                        int strNE( char *s1, char *s2 )
  1567.  
  1568.        strnEQ  Test two strings to see if they are equal.  The
  1569.                len parameter indicates the number of bytes to
  1570.                compare.  Returns true or false.
  1571.  
  1572.                        int strnEQ( char *s1, char *s2 )
  1573.  
  1574.        strnNE  Test two strings to see if they are different.
  1575.                The len parameter indicates the number of bytes to
  1576.                compare.  Returns true or false.
  1577.  
  1578.                        int strnNE( char *s1, char *s2, int len )
  1579.  
  1580.        sv_2mortal
  1581.                Marks an SV as mortal.  The SV will be destroyed
  1582.                when the current context ends.
  1583.  
  1584.                        SV*     sv_2mortal _((SV* sv));
  1585.  
  1586.        sv_bless
  1587.                Blesses an SV into a specified package.  The SV
  1588.                must be an RV.  The package must be designated by
  1589.                its stash (see gv_stashpv()).  The refcount of the
  1590.                SV is unaffected.
  1591.  
  1592.                        SV*     sv_bless _((SV* sv, HV* stash));
  1593.  
  1594.        sv_catpv
  1595.                Concatenates the string onto the end of the string
  1596.                which is in the SV.
  1597.  
  1598.                        void    sv_catpv _((SV* sv, char* ptr));
  1599.  
  1600.        sv_catpvn
  1601.                Concatenates the string onto the end of the string
  1602.                which is in the SV.  The len indicates number of
  1603.                bytes to copy.
  1604.  
  1605.                        void    sv_catpvn _((SV* sv, char* ptr, STRLEN len));
  1606.  
  1607.        sv_catsv
  1608.                Concatentates the string from SV ssv onto the end
  1609.                of the string in SV dsv.
  1610.  
  1611.                        void    sv_catsv _((SV* dsv, SV* ssv));
  1612.  
  1613.        SvCUR   Returns the length of the string which is in the
  1614.                SV.  See SvLEN.
  1615.  
  1616.                        int SvCUR (SV* sv)
  1617.  
  1618.        SvCUR_set
  1619.                Set the length of the string which is in the SV.
  1620.                See SvCUR.
  1621.  
  1622.                        SvCUR_set (SV* sv, int val )
  1623.  
  1624.        SvEND   Returns a pointer to the last character in the
  1625.                string which is in the SV.  See SvCUR.  Access the
  1626.                character as
  1627.  
  1628.                        *SvEND(sv)
  1629.  
  1630.        SvGROW  Expands the character buffer in the SV.
  1631.  
  1632.                        char * SvGROW( SV* sv, int len )
  1633.  
  1634.        SvIOK   Returns a boolean indicating whether the SV
  1635.                contains an integer.
  1636.  
  1637.                        int SvIOK (SV* SV)
  1638.  
  1639.        SvIOK_off
  1640.                Unsets the IV status of an SV.
  1641.  
  1642.                        SvIOK_off (SV* sv)
  1643.  
  1644.        SvIOK_on
  1645.                Tells an SV that it is an integer.
  1646.  
  1647.                        SvIOK_on (SV* sv)
  1648.  
  1649.        SvIOKp  Returns a boolean indicating whether the SV
  1650.                contains an integer.  Checks the private setting.
  1651.                Use SvIOK.
  1652.  
  1653.                        int SvIOKp (SV* SV)
  1654.  
  1655.        sv_isa  Returns a boolean indicating whether the SV is
  1656.                blessed into the specified class.  This does not
  1657.                know how to check for subtype, so it doesn't work
  1658.                in an inheritance relationship.
  1659.  
  1660.                        int     sv_isa _((SV* sv, char* name));
  1661.  
  1662.        SvIV    Returns the integer which is in the SV.
  1663.  
  1664.                        int SvIV (SV* sv)
  1665.  
  1666.        sv_isobject
  1667.                Returns a boolean indicating whether the SV is an
  1668.                RV pointing to a blessed object.  If the SV is not
  1669.                an RV, or if the object is not blessed, then this
  1670.                will return false.
  1671.  
  1672.                        int     sv_isobject _((SV* sv));
  1673.  
  1674.        SvIVX   Returns the integer which is stored in the SV.
  1675.  
  1676.                        int  SvIVX (SV* sv);
  1677.  
  1678.        SvLEN   Returns the size of the string buffer in the SV.
  1679.                See SvCUR.
  1680.  
  1681.                        int SvLEN (SV* sv)
  1682.  
  1683.        sv_magic
  1684.                Adds magic to an SV.
  1685.  
  1686.                        void    sv_magic _((SV* sv, SV* obj, int how, char* name, I32 namlen));
  1687.  
  1688.        sv_mortalcopy
  1689.                Creates a new SV which is a copy of the original
  1690.                SV.  The new SV is marked as mortal.
  1691.  
  1692.                        SV*     sv_mortalcopy _((SV* oldsv));
  1693.  
  1694.        SvOK    Returns a boolean indicating whether the value is
  1695.                an SV.
  1696.  
  1697.                        int SvOK (SV* sv)
  1698.  
  1699.        sv_newmortal
  1700.                Creates a new SV which is mortal.  The refcount of
  1701.                the SV is set to 1.
  1702.  
  1703.                        SV*     sv_newmortal _((void));
  1704.  
  1705.        sv_no   This is the false SV.  See sv_yes.  Always refer
  1706.                to this as &sv_no.
  1707.  
  1708.        SvNIOK  Returns a boolean indicating whether the SV
  1709.                contains a number, integer or double.
  1710.                        int SvNIOK (SV* SV)
  1711.  
  1712.        SvNIOK_off
  1713.                Unsets the NV/IV status of an SV.
  1714.  
  1715.                        SvNIOK_off (SV* sv)
  1716.  
  1717.        SvNIOKp Returns a boolean indicating whether the SV
  1718.                contains a number, integer or double.  Checks the
  1719.                private setting.  Use SvNIOK.
  1720.  
  1721.                        int SvNIOKp (SV* SV)
  1722.  
  1723.        SvNOK   Returns a boolean indicating whether the SV
  1724.                contains a double.
  1725.  
  1726.                        int SvNOK (SV* SV)
  1727.  
  1728.        SvNOK_off
  1729.                Unsets the NV status of an SV.
  1730.  
  1731.                        SvNOK_off (SV* sv)
  1732.  
  1733.        SvNOK_on
  1734.                Tells an SV that it is a double.
  1735.  
  1736.                        SvNOK_on (SV* sv)
  1737.  
  1738.        SvNOKp  Returns a boolean indicating whether the SV
  1739.                contains a double.  Checks the private setting.
  1740.                Use SvNOK.
  1741.  
  1742.                        int SvNOKp (SV* SV)
  1743.  
  1744.        SvNV    Returns the double which is stored in the SV.
  1745.  
  1746.                        double SvNV (SV* sv);
  1747.  
  1748.        SvNVX   Returns the double which is stored in the SV.
  1749.  
  1750.                        double SvNVX (SV* sv);
  1751.  
  1752.        SvPOK   Returns a boolean indicating whether the SV
  1753.                contains a character string.
  1754.  
  1755.                        int SvPOK (SV* SV)
  1756.  
  1757.        SvPOK_off
  1758.                Unsets the PV status of an SV.
  1759.  
  1760.                        SvPOK_off (SV* sv)
  1761.  
  1762.        SvPOK_on
  1763.                Tells an SV that it is a string.
  1764.  
  1765.                        SvPOK_on (SV* sv)
  1766.  
  1767.        SvPOKp  Returns a boolean indicating whether the SV
  1768.                contains a character string.  Checks the private
  1769.                setting.  Use SvPOK.
  1770.  
  1771.                        int SvPOKp (SV* SV)
  1772.  
  1773.        SvPV    Returns a pointer to the string in the SV, or a
  1774.                stringified form of the SV if the SV does not
  1775.                contain a string.  If len is na then Perl will
  1776.                handle the length on its own.
  1777.  
  1778.                        char * SvPV (SV* sv, int len )
  1779.  
  1780.        SvPVX   Returns a pointer to the string in the SV.  The SV
  1781.                must contain a string.
  1782.  
  1783.                        char * SvPVX (SV* sv)
  1784.  
  1785.        SvREFCNT
  1786.                Returns the value of the object's refcount.
  1787.  
  1788.                        int SvREFCNT (SV* sv);
  1789.  
  1790.        SvREFCNT_dec
  1791.                Decrements the refcount of the given SV.
  1792.  
  1793.                        void SvREFCNT_dec (SV* sv)
  1794.  
  1795.        SvREFCNT_inc
  1796.                Increments the refcount of the given SV.
  1797.  
  1798.                        void SvREFCNT_inc (SV* sv)
  1799.  
  1800.        SvROK   Tests if the SV is an RV.
  1801.  
  1802.                        int SvROK (SV* sv)
  1803.  
  1804.        SvROK_off
  1805.                Unsets the RV status of an SV.
  1806.  
  1807.                        SvROK_off (SV* sv)
  1808.  
  1809.        SvROK_on
  1810.                Tells an SV that it is an RV.
  1811.  
  1812.                        SvROK_on (SV* sv)
  1813.  
  1814.        SvRV    Dereferences an RV to return the SV.
  1815.  
  1816.                        SV*     SvRV (SV* sv);
  1817.  
  1818.        sv_setiv
  1819.                Copies an integer into the given SV.
  1820.  
  1821.                        void    sv_setiv _((SV* sv, IV num));
  1822.  
  1823.        sv_setnv
  1824.                Copies a double into the given SV.
  1825.  
  1826.                        void    sv_setnv _((SV* sv, double num));
  1827.  
  1828.        sv_setpv
  1829.                Copies a string into an SV.  The string must be
  1830.                null-terminated.
  1831.  
  1832.                        void    sv_setpv _((SV* sv, char* ptr));
  1833.  
  1834.        sv_setpvn
  1835.                Copies a string into an SV.  The len parameter
  1836.                indicates the number of bytes to be copied.
  1837.  
  1838.                        void    sv_setpvn _((SV* sv, char* ptr, STRLEN len));
  1839.  
  1840.        sv_setref_iv
  1841.                Copies an integer into an SV, optionally blessing
  1842.                the SV.  The SV must be an RV.  The classname
  1843.                argument indicates the package for the blessing.
  1844.                Set classname to Nullch to avoid the blessing.
  1845.                The new SV will be returned and will have a
  1846.                refcount of 1.
  1847.  
  1848.                        SV*     sv_setref_iv _((SV *rv, char *classname, IV iv));
  1849.  
  1850.        sv_setref_nv
  1851.                Copies a double into an SV, optionally blessing
  1852.                the SV.  The SV must be an RV.  The classname
  1853.                argument indicates the package for the blessing.
  1854.                Set classname to Nullch to avoid the blessing.
  1855.                The new SV will be returned and will have a
  1856.                refcount of 1.
  1857.  
  1858.                        SV*     sv_setref_nv _((SV *rv, char *classname, double nv));
  1859.  
  1860.        sv_setref_pv
  1861.                Copies a pointer into an SV, optionally blessing
  1862.                the SV.  The SV must be an RV.  If the pv argument
  1863.                is NULL then sv_undef will be placed into the SV.
  1864.                The classname argument indicates the package for
  1865.                the blessing.  Set classname to Nullch to avoid
  1866.                the blessing.  The new SV will be returned and
  1867.                will have a refcount of 1.
  1868.  
  1869.                        SV*     sv_setref_pv _((SV *rv, char *classname, void* pv));
  1870.  
  1871.                Do not use with integral Perl types such as HV,
  1872.                AV, SV, CV, because those objects will become
  1873.                corrupted by the pointer copy process.
  1874.  
  1875.                Note that sv_setref_pvn copies the string while
  1876.                this copies the pointer.
  1877.  
  1878.        sv_setref_pvn
  1879.                Copies a string into an SV, optionally blessing
  1880.                the SV.  The lenth of the string must be specified
  1881.                with n.  The SV must be an RV.  The classname
  1882.                argument indicates the package for the blessing.
  1883.                Set classname to Nullch to avoid the blessing.
  1884.                The new SV will be returned and will have a
  1885.                refcount of 1.
  1886.  
  1887.                        SV*     sv_setref_pvn _((SV *rv, char *classname, char* pv, I32 n));
  1888.  
  1889.                Note that sv_setref_pv copies the pointer while
  1890.                this copies the string.
  1891.  
  1892.        sv_setsv
  1893.                Copies the contents of the source SV ssv into the
  1894.                destination SV dsv.  (NOTE: If ssv has the
  1895.                SVs_TEMP bit set, sv_setsv may simply steal the
  1896.                string from ssv and give it to dsv, leaving ssv
  1897.                empty.  Caveat caller.)
  1898.                        void    sv_setsv _((SV* dsv, SV* ssv));
  1899.  
  1900.        SvSTASH Returns the stash of the SV.
  1901.  
  1902.                        HV * SvSTASH (SV* sv)
  1903.  
  1904.        SVt_IV  Integer type flag for scalars.  See svtype.
  1905.  
  1906.        SVt_PV  Pointer type flag for scalars.  See svtype.
  1907.  
  1908.        SVt_PVAV
  1909.                Type flag for arrays.  See svtype.
  1910.  
  1911.        SVt_PVCV
  1912.                Type flag for code refs.  See svtype.
  1913.  
  1914.        SVt_PVHV
  1915.                Type flag for hashes.  See svtype.
  1916.  
  1917.        SVt_PVMG
  1918.                Type flag for blessed scalars.  See svtype.
  1919.  
  1920.        SVt_NV  Double type flag for scalars.  See svtype.
  1921.  
  1922.        SvTRUE  Returns a boolean indicating whether Perl would
  1923.                evaluate the SV as true or false, defined or
  1924.                undefined.
  1925.  
  1926.                        int SvTRUE (SV* sv)
  1927.  
  1928.        SvTYPE  Returns the type of the SV.  See svtype.
  1929.  
  1930.                        svtype  SvTYPE (SV* sv)
  1931.  
  1932.        svtype  An enum of flags for Perl types.  These are found
  1933.                in the file sv.h in the svtype enum.  Test these
  1934.                flags with the SvTYPE macro.
  1935.  
  1936.        SvUPGRADE
  1937.                Used to upgrade an SV to a more complex form.  See
  1938.                svtype.
  1939.  
  1940.        sv_undef
  1941.                This is the undef SV.  Always refer to this as
  1942.                &sv_undef.
  1943.  
  1944.        sv_usepvn
  1945.                Tells an SV to use ptr to find its string value.
  1946.                Normally the string is stored inside the SV; this
  1947.                allows the SV to use an outside string.  The
  1948.                string length, len, must be supplied.  This
  1949.                function will realloc the memory pointed to by
  1950.                ptr, so that pointer should not be freed or used
  1951.                by the programmer after giving it to sv_usepvn.
  1952.  
  1953.                        void    sv_usepvn _((SV* sv, char* ptr, STRLEN len));
  1954.  
  1955.        sv_yes  This is the true SV.  See sv_no.  Always refer to
  1956.                this as &sv_yes.
  1957.  
  1958.        THIS    Variable which is setup by xsubpp to designate the
  1959.                object in a C++ XSUB.  This is always the proper
  1960.                type for the C++ object.  See CLASS and the perlxs
  1961.                manpage.
  1962.  
  1963.        toLOWER Converts the specified character to lowercase.
  1964.  
  1965.                        int toLOWER (char c)
  1966.  
  1967.        toUPPER Converts the specified character to uppercase.
  1968.  
  1969.                        int toUPPER (char c)
  1970.  
  1971.        warn    This is the XSUB-writer's interface to Perl's warn
  1972.                function.  Use this function the same way you use
  1973.                the C printf function.  See croak().
  1974.  
  1975.        XPUSHi  Push an integer onto the stack, extending the
  1976.                stack if necessary.  See PUSHi.
  1977.  
  1978.                        XPUSHi(int d)
  1979.  
  1980.        XPUSHn  Push a double onto the stack, extending the stack
  1981.                if necessary.  See PUSHn.
  1982.  
  1983.                        XPUSHn(double d)
  1984.  
  1985.        XPUSHp  Push a string onto the stack, extending the stack
  1986.                if necessary.  The len indicates the length of the
  1987.                string.  See PUSHp.
  1988.  
  1989.                        XPUSHp(char *c, int len)
  1990.  
  1991.        XPUSHs  Push an SV onto the stack, extending the stack if
  1992.                necessary.  See PUSHs.
  1993.  
  1994.                        XPUSHs(sv)
  1995.  
  1996.        XSRETURN
  1997.                Return from XSUB, indicating number of items on
  1998.                the stack.  This is usually handled by xsubpp.
  1999.  
  2000.                        XSRETURN(x);
  2001.  
  2002.        XSRETURN_EMPTY
  2003.                Return from an XSUB immediately.
  2004.  
  2005.                        XSRETURN_EMPTY;
  2006.  
  2007.        XSRETURN_NO
  2008.                Return false from an XSUB immediately.
  2009.  
  2010.                        XSRETURN_NO;
  2011.  
  2012.        XSRETURN_UNDEF
  2013.                Return undef from an XSUB immediately.
  2014.  
  2015.                        XSRETURN_UNDEF;
  2016.  
  2017.        XSRETURN_YES
  2018.                Return true from an XSUB immediately.
  2019.  
  2020.                        XSRETURN_YES;
  2021.  
  2022.        Zero    The XSUB-writer's interface to the C memzero
  2023.                function.  The d is the destination, n is the
  2024.                number of items, and t is the type.
  2025.  
  2026.                        (void) Zero( d, n, t );
  2027.  
  2028. AUTHOR
  2029.        Jeff Okamoto <okamoto@corp.hp.com>
  2030.  
  2031.        With lots of help and suggestions from Dean Roehrich,
  2032.        Malcolm Beattie, Andreas Koenig, Paul Hudson, Ilya
  2033.        Zakharevich, Paul Marquess, Neil Bowers, Matthew Green,
  2034.        Tim Bunce, and Spider Boardman.
  2035.  
  2036.        API Listing by Dean Roehrich <roehrich@cray.com>.
  2037.  
  2038. DATE
  2039.        Version 20: 1995/12/14
  2040.